/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NotificationDialog.java
 *
 * Created on May 3, 2011, 12:11:42 AM
 */
package vn.support.ui.frame;

import com.sun.awt.AWTUtilities;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionListener;
import vn.support.system.SystemProperties;

/**
 *
 * @author nttuyen
 */
public class NotificationDialog extends javax.swing.JDialog {

    /** Creates new form NotificationDialog */
    public NotificationDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        this.setUndecorated(true);
        initComponents();
        this.init();
    }

    public final void init() {
        
        this.jButtonAccept.setText(SystemProperties.getValue("ui.notification.button.accept.label"));
        this.jButtonRefuse.setText(SystemProperties.getValue("ui.notification.button.refuse.label"));
        
        this.setResizable(false);
        if(AWTUtilities.isTranslucencySupported(AWTUtilities.Translucency.TRANSLUCENT)) {
            AWTUtilities.setWindowOpacity(this, 0.9f);
        }
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension screenSize = tk.getScreenSize();
        int screenHeight = screenSize.height;
        //int screenWidth = screenSize.width;
        this.setLocation(0, screenHeight - this.getHeight() - 70);
        this.setAlwaysOnTop(true);
        this.pack();
    }
    
    public void setMessage(String message) {
        this.jLabelMessage.setText(message);
    }
    public void addAcceptListener(ActionListener listener) {
        this.jButtonAccept.addActionListener(listener);
    }
    public void addRefuseListener(ActionListener listener) {
        this.jButtonRefuse.addActionListener(listener);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabelMessage = new javax.swing.JLabel();
        jButtonAccept = new javax.swing.JButton();
        jButtonRefuse = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabelMessage.setFont(new java.awt.Font("Times New Roman", 0, 24)); // NOI18N
        jLabelMessage.setForeground(new java.awt.Color(255, 0, 0));
        jLabelMessage.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelMessage.setText("Message");
        jLabelMessage.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jButtonAccept.setText("accept");
        jButtonAccept.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAcceptActionPerformed(evt);
            }
        });

        jButtonRefuse.setText("refuse");
        jButtonRefuse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRefuseActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabelMessage, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(jButtonAccept, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 126, Short.MAX_VALUE)
                .addComponent(jButtonRefuse, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(57, 57, 57))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabelMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonAccept, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonRefuse, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(24, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonRefuseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRefuseActionPerformed
        this.dispose();
    }//GEN-LAST:event_jButtonRefuseActionPerformed

    private void jButtonAcceptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAcceptActionPerformed
        this.dispose();
    }//GEN-LAST:event_jButtonAcceptActionPerformed

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonAccept;
    private javax.swing.JButton jButtonRefuse;
    private javax.swing.JLabel jLabelMessage;
    // End of variables declaration//GEN-END:variables
}
